<template>
	<view class="modal">
		<view class="modal-bkg" />
		<view class="modal-pop">
			<view class="close" @tap="close">
				<img src="../../static/icon/icon_16_close_w@2x.png" alt="">
			</view>
			<view class="pop-main">
				<view class="title"></view>
				<view class="main">
					<view v-if="lotteryResult.status == 3 || lotteryResult.status == 4 || lotteryResult.status == 1">
						<view class="ended">
							<img src="../../static/img/img_108_bobo_sigh@2x.png" alt="">
							<view class="desc">
								<span v-if="lotteryResult.status == 4">手慢了，该积木被抢光了</span>
								<span v-else-if="lotteryResult.status == 3">来晚了，该积木兑换已截止</span>
								<span v-else-if="lotteryResult.status == 1">积分不足，去做任务吧</span>
							</view>
						</view>
					</view>
					<view v-else-if="lotteryResult.status == 5 "> 
					<!-- 抽奖，并且中奖 -->
						<view class="ended">
							<img src="../../static/img/img_64_task_thumb_07@2x.png" alt="">
							<view class="desc" v-if="lotteryResult.type == 1">
								<span>恭喜您抽中 <span class='shop_name'>{{lotteryResult.shop_name}}</span></span>
							</view>
							<view class="desc" v-else>
								<span><span class='shop_name'>{{lotteryResult.shop_name}}</span> 兑换成功</span>
							</view>
						</view>
					</view>
					<!-- 抽奖，没中奖 -->
					<view v-else-if="lotteryResult.status == 6">
						<view class="ended">
							<img src="../../static/img/img_108_bobo_sigh@2x.png" alt="">
							<view class="desc">
								<span>真遗憾，这次没有中奖～</span>
							</view>
						</view>
					</view>
					<view v-else-if="lotteryResult.status == 0 || lotteryResult.status == 2">
						<view class="status">
							<view v-if="lotteryResult.status == 0">参与抽奖成功</view>
							<view v-if="lotteryResult.status == 2">您已经参与过了</view>
							
						</view>
						<view class="result">
							您的抽奖号<span class="result-num">{{lotteryResult.lottery_code}}</span>
						</view>
						<view class="result-desc">
							*自动开奖后，您可通过短信或微信服务通知获取中奖信息。中奖后，请及时前往中奖纪录中完善收货信息
						</view>
					</view>
					<view v-else>
						<view class="ended">
							<img src="../../static/img/img_108_bobo_sigh@2x.png" alt="">
							<view class="desc">
								抽奖出错了，请重新抽奖
							</view>
						</view>
					</view>
				</view>
				<view class="next-btn">
					<view v-if="lotteryResult.status == 1" @click="switchIndex">去做任务</view>
					<view v-else-if="lotteryResult.status == 4 || lotteryResult.status == 3" @click="close">看看其他积木</view>
					<view v-else-if="lotteryResult.status == 5" @click="jumpUser">前往查看</view>
					<view v-else @click="close">继续抽其他积木</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	export default {
		name: 'wx-auth',
		props: {
			authType: {
				type: Array,
				default(){
					return ['authAvatar']
				}
			},
			lotteryResult:{ // 1  表示抽奖成功， 2 表示重复抽奖 3 表示 商品抽完 4 表示 活动结束 5 表示积分不足
			//0 1、2 3.4 分别代表，抽奖成功 积分不足，已经抽过,兑换截止，被抢光等
				type: Object,
				default(){
					return {
						status: 3
					}
				}
			}
		},
		computed:{
			...mapState(['userinfo'])
		},
		data() {
			return {
				videolink: '从多少上的车',
				// lotteryResult: {
				// 	status: 4,
				// 	shop_name: '换了中国年'
				// }
			};
		},
		methods: {
			jumpUser(){
				uni.switchTab({
				    url: '/pages/user/user'
				});
			},
			close(){
				console.log('关闭了')
				uni.$emit('pop_close')
			},
			switchIndex(){
				this.close()
				uni.switchTab({
				    url: '/pages/index/index'
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.modal{
		position: fixed;
		top: 0;
		z-index: 99;
		.modal-bkg{
			position: fixed;
			top: 0;
			background-color: rgba(0,0,0,.5);
			width: 100vw;
			height: 100vh;
		}
		.modal-pop{
			position: absolute;
			top: calc(50vh - 146px);
			left: calc(50vw - 160px);
			width: 320px;
			height: 292px;
			background-image: url('@/static/index/img_modal_card_01@2x.png');
			background-size: 320px 292px;
			.close{
				position: absolute;
				top: -56px;
				right: 0;
				width: 72px;
				height: 56px;
				background: url('@/static/btn/btn_32_ghost_shadow_nor@2x.png');
				background-size: 72px 56px;
				display: flex;
				align-items: center;
				justify-content: center;
				img{
					width: 15px;
					height: 15px;
				}
			}
			.pop-main{
				width: 258px;
				margin: 26px auto;
				.title{
					width: 64px;
					height: 22px;
					font-size: 16px;
					color: #F82045;
					font-weight: 600;
				}
				.main{
					margin-top: 49px;
					text-align: center;
					width: 100%;
					.status{
						margin-top: -19px
					}
					.result{
						height: 48px;
						margin: 0 auto;
						border-radius: 8px;
						line-height: 48px;
						background: #FFECEE;
						border-radius: 8px;
						padding-left: 10px;
						padding-right: 10px;
						margin-top: 12px;
						.result-num{
							font-size: 18px;
							color: #F82045;
							margin-left: 6px;
						}
					}
					.result-desc{
						width: 100%;
						background: #FDF8DF;
						border-radius: 8px;
						font-size: 10px;
						color: #805340;
						margin-top: 20px;
						padding: 12px;
					}
					.ended{
						img{
							width: 96px;
							height: 96px;
							margin: -10px auto 0;
						}
						.desc{
							font-size: 16px;
							text-align: center;
							font-weight: 600;
							margin-top: 16px;
							.shop_name{
								color: #F82045;
								padding-left: 4rpx;
							}
						}
					}
					
				}
				.next-btn{
					width: 152px;
					height: 56px;
					margin: 0 auto;
					text-align: center;
					line-height: 56px;
					background: url('@/static/btn/btn_32_red_152_shadow_nor@2x.png');
					background-size: 152px 56px;
					background-repeat: no-repeat;
					color: #FFFFFF;
					font-weight: 500;
				}
			}
			
		}
		
	}
</style>
